/*
 * TreeStringGenerator.java
 *
 * Created on September 12, 2006, 5:04 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package galronnlp.util;

/**
 * 
 * 
 * @author Dennis N. Mehay
 * An interface for TreeStringGenerator objects -- that is
 * objects that are responsible for producing sensible <code>String</code>
 * representations of <code>Tree</code> objects.
 */
public abstract class TreeStringGenerator {
    /* Whether or not we display inside probabilities of <code>Trees</code>*/
    protected boolean displayProb = false;
    
    /* Generates a multiline (a.k.a. pretty-print, indented representation of a
     * <code>Tree</code>.
     *
     * @param t The <code>Tree</code> to be represented as a <code>String</code>.
     * @param indent An <code>int</code> that specifies how many spaces over each
     *               embedded level should be indented.
     *
     *
     */
    public abstract String generateMultilineString(Tree t, int indent);
    
    /* Generates a <code>String</code> representation of a <code>Tree</code> without
     * newlines or indentation levels.  The <code>indent</code> parameter is simply
     * to specify
     *
     * @param t The <code>Tree</code> to be represented as a <code>String</code>.
     * @param spacing An <code>int</code> that specifies how much space is given
     *               between bracketed constituents.  (N.B. this is NOT used to indent
     *               levels of embedding in the <code>String</code> output.)
     */
    public abstract String generateSingleLineString(Tree t);

    /* Generates a <code>String</code> representation of the node of a tree.
     * It's just a clean way of generating either categories like 
     *
     * @param t The <code>Tree</code> to be represented as a <code>String</code>.
     * @param spacing An <code>int</code> that specifies how much space is given
     *               between bracketed constituents.  (N.B. this is NOT used to indent
     *               levels of embedding in the <code>String</code> output.)
     */
    protected String generateNodeString(Tree t) {
        String ret = t.category.toString();
        if(this.displayProb) {
            ret += ":" + t.prob();
        }
        return ret;
    }
    
}
